import { createRouter, createWebHistory } from "vue-router";
import LoginComponent from "../components/LoginComponent.vue";
import UserComponent from "../components/UserComponent.vue";
import DoctorComponent from "../components/DoctorComponent.vue";
import UserAppointment from "@/components/UserAppointment.vue";
import UserPayment from "@/components/UserPayment.vue";
import UserMyAppointments from "@/components/UserMyAppointments.vue";
import DoctorPatientList from "@/components/DoctorPatientList.vue";
import DoctorEditMedicalRecord from "@/components/DoctorEditMedicalRecord.vue";
import UserCheckRecord from "@/components/UserCheckRecord.vue";
import DoctorDispensary from "@/components/DoctorDispensary.vue";
import DoctorDrugStock from "@/components/DoctorDrugStock.vue";
const routes = [
  {
    path: "/",
    name: "Login",
    component: LoginComponent,
    props: true,
  },
  {
    path: "/user",
    name: "User",
    component: UserComponent,
    redirect: "/user/appointment",
    children: [
      {
        path: "appointment",
        name: "UserAppointment",
        component: UserAppointment,
      },
      {
        path: "payment",
        name: "UserPayment",
        component: UserPayment,
      },
      {
        path: "my-appointments",
        name: "UserMyAppointments",
        component: UserMyAppointments,
      },
      {
        path: "check-record/:id",
        name: "UserCheckRecord",
        component: UserCheckRecord,
        props: true, // 允许将路由参数作为组件的 props
      },
    ],
  },
  {
    path: "/doctor",
    name: "Doctor",
    component: DoctorComponent,
    redirect: "/doctor/patientList",
    children: [
      {
        path: "patientList",
        name: "DoctorPatientList",
        component: DoctorPatientList,
      },
      {
        path: "editMedicalRecord",
        name: "DoctorEditMedicalRecord",
        component: DoctorEditMedicalRecord,
      },
      {
        path: "dispensary",
        name: "DoctorDispensary",
        component: DoctorDispensary,
      },
      {
        path: "drugStock/:drugs",
        name: "DoctorDrugStock",
        component: DoctorDrugStock,
        props: true,
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
